package com.nulldev.util.security.encryptAPI_rw.impls.rsa;

import com.nulldev.util.JVM.JVM;
import com.nulldev.util.VariableAPI.ByteUtil;
import com.nulldev.util.io.FastIO.FastIO;
import com.nulldev.util.security.encryptAPI_rw.api.IPKPKKeyGenerator.PKPKSet;

public class RSACipherTest {

	public static void main(String[] args) {
		final RSACipher rsa = new RSACipher(2048);
		JVM.println("Generating a RSA-2048 set...");
		final PKPKSet set = rsa.makeKey(2048);
		JVM.println("PUBL: " + ByteUtil.getHex(set.getPublicKey()));
		JVM.println("PRIV: " + ByteUtil.getHex(set.getPrivateKey()));
		final String testString = "Hello RSA world!";
		final byte[] enc = rsa.encrypt(testString.getBytes(), set.getPrivateKey(), set.getPublicKey());
		final byte[] dec = rsa.decrypt(enc, set.getPrivateKey(), set.getPublicKey());
		final String out = new String(dec);
		JVM.println("out: " + out);
		FastIO.get().flush();
		JVM.exit();
	}

}
